package projectchumashgeniusproject;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import projectchumashgeniusproject.ProjectChumashGeniusProject.BookName;

public class Chapter implements Serializable
{
    private int chapterNum;
    private BookName book;
    private List<Verse> verses;
    
    public Chapter(int cn, BookName bn)
    {
        this(cn, bn, new ArrayList<Verse>());
    }
    public Chapter(int cn, BookName bn, ArrayList<Verse> v) 
    {
        this.chapterNum = cn;
        this.book = bn;
        this.verses = new ArrayList<>(v);
    }
    public int getChapterNumber()
    {
        int cn = chapterNum;
        return cn;
    }
    public BookName getBook()
    {
        BookName bn = book;
        return bn;
    }
    public List<Verse> getVerses()
    {
        return new ArrayList<>(verses);
    }
    public void addVerse(Verse v)
    {
        verses.add(v.getVerseNumber() - 1, v);
    }
    public void deleteVerse(int i)
    {
        verses.remove(i);
    }
    @Override
    public int hashCode()
    {
        int hash = 3;
        hash = 67 * hash + this.chapterNum;
        hash = 67 * hash + Objects.hashCode(this.book);
        hash = 67 * hash + Objects.hashCode(this.verses);
        return hash;
    }
    @Override
    public boolean equals(Object obj)
    {
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        
        final Chapter other = (Chapter) obj;
        
        if (this.chapterNum != other.chapterNum)
            return false;
        if (this.book != other.book)
            return false;
        if (!Objects.equals(this.verses, other.verses))
            return false;
        
        return true;
    }
}